import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
/** 主要用于alias文件路径别名 */
import { resolve } from "path";

/** 路径查找 */
const pathResolve = (dir: string): string => {
  return resolve(__dirname, ".", dir);
};

/** 设置别名 */
const alias: Record<string, string> = {
  "@": pathResolve("src"),
  "@build": pathResolve("build"),
};

export default defineConfig({
  plugins: [vue(), vueJsx()],

  /** 配置别名 */
  resolve: {
    alias,
  },

  /** 单独处理mixin样式 */
  css: {
    preprocessorOptions: {
      scss: {
        /** 全局样式 */
        additionalData: '@import "./src/style/index.scss";',
      },
    },
  },
});
